package com.ihisun.tmhcms.controller.projectcontroller;

import com.ihisun.tmhcms.core.dto.projectdto.EditProjectClassDto;
import com.ihisun.tmhcms.core.dto.projectdto.EditProjectDto;
import com.ihisun.tmhcms.core.dto.projectdto.SearchProjectClassDto;
import com.ihisun.tmhcms.core.service.projectservice.EditProjectService;
import com.ihisun.tmhcms.core.service.projectservice.EditprojectClassService;
import com.ihisun.tmhcms.core.service.projectservice.ProjectClassService;
import com.ihisun.tmhcms.core.service.projectservice.ProjectService;
import com.ihisun.tmhcms.core.vo.ProjectVo;
import com.ihisun.tmhcms.core.vo.SearchProjectClassVo;
import com.ihisun.tmhcms.utils.ResponseVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(tags = "项目相关Api")
@RequestMapping("project")
@RestController
public class ProjectController {

    @Resource
    EditProjectService editProjectService;
    @Resource
    EditprojectClassService editprojectClassService;
    @Resource
    ProjectClassService projectClassService;
    @Resource
    ProjectService projectService;

    @PostMapping("/editProject")
    @ApiOperation(value = "编辑项目", response = EditProjectDto.class)
    public ResponseVo editProject(@RequestBody EditProjectDto editProjectDto) {
        return editProjectService.editProject(editProjectDto);
    }


    @GetMapping("/updateState")
    @ApiOperation(value = "修改项目状态 1正常  2下架   3删除")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "projectId", value = "项目id", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "valueState", value = "状态值", dataType = "String", paramType = "query"),
    })
    public ResponseVo updateState(String projectId, String valueState) {
        return editProjectService.findByProjectId(projectId, Integer.valueOf(valueState));
    }


    @GetMapping("/searchProject")
    @ApiOperation(value = "多条件搜索", response = ProjectVo.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "项目名 医生名", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "typeName", value = "项目分类名", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "state", value = "项目状态", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "分页起始数", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "pageNum", value = "长度", dataType = "String", paramType = "query")
    })
    public ResponseVo searchProject(String name, String typeName, String state, String pageSize, String pageNum) {
        return editProjectService.searchProject(name, typeName, Integer.parseInt(state), Integer.parseInt(pageSize), Integer.parseInt(pageNum));
    }

    @GetMapping("/projectInfo")
    @ApiOperation(value = "项目详情",response =ProjectVo.class )
    @ApiImplicitParam(name = "projectId", value = "项目Id", dataType = "String", paramType = "query")
    public ResponseVo projectInfo(String projectId){
        return projectService.projectInfo(projectId);
    }


    @PostMapping("/editProjectClass")
    @ApiOperation(value = "编辑项目分类", response = EditProjectClassDto.class)
    private ResponseVo editprojectClass(@RequestBody EditProjectClassDto editProjectClassDto) {
        return editprojectClassService.editProjectClass(editProjectClassDto);
    }

    @GetMapping("/editProjectClassState")
    @ApiOperation(value = "修改项目分类状态")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "projectClassId", value = "项目项目分类Id", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "state", value = "状态", dataType = "String", paramType = "query")
    })
    private ResponseVo editProjectClassState(String projectClassId, String state) {
        return editprojectClassService.editProjectClassState(projectClassId, Integer.parseInt(state));
    }


    @PostMapping("/searchProjectClass")
    @ApiOperation(value = "收索项目分类", response = SearchProjectClassVo.class)
    public ResponseVo searchProjectClass(@RequestBody SearchProjectClassDto searchProjectClassDto) {
        return projectClassService.searchProjectClass(searchProjectClassDto);
    }
}
